/*
要求实现两个函数：
1. 2个线程实现1-10000加法总和
2. 2个线程实现1-10000交替加法总和
*/

#include <iostream>
#include <mutex>
#include <thread>
#include <functional>

using namespace std;

void myAdd(int start, int end, int & sum){
	while(start <= end){
		sum += start;
		start++;
	}
	cout << sum << endl;
}

void myPrint(int & p){
	cout << p << endl;
}

int main(){
	int a  = 0;
	// myAdd(1, 10000, ref(a));
	// cout << "a:" << a << endl;
	
	// int s1 = 0, s2 = 0;
	// thread t1(myAdd, 1, 5000, ref(s1));
	thread t1(myPrint, ref(a));
	// thread t2(myAdd, 5001, 10000, ref(s2));
	t1.join();
	// t2.join();
	// cout << "thread:" << s1 + s2 << endl;
	
	
	return 0;
}